package com.yeepal.action;

import com.yeepal.bean.User;

public class LoginAction extends BaseAction {
	private User user = new User();
	public String resule;
	private String validateCode = "";

	public void setValidateCode(String validateCode) {
		this.validateCode = validateCode;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	// public String execute() throws Exception{
	// return SUCCESS;
	// }

	public String execute() throws Exception {
		// if(this.session().getAttribute("rand")!=null){
		// if(this.validateCode.equals(this.session().getAttribute("rand").
		// toString())){
		// User resultUser=this.logicDAO().getUserDAO().Login(user);
		// if(resultUser!=null){
		// this.session().setAttribute("user", resultUser);
		// }
		// }
		// }

		User resultUser = this.logicDAO().getUserDAO().Login(user);
		if (resultUser != null) {
			this.session().setAttribute("user", resultUser);
			resule = SUCCESS;
			return SUCCESS;
		} else {
			resule = ERROR;
			return ERROR;
		}
	}

	public String getValidateCode() {
		return validateCode;
	}
}
